Namespace MyDAO
    Public Class MyContainsCondition
        Inherits MyDataConditionBase

        Public Expression1 As MyDataExpressionBase
        Public op As MyContainsOperator
        Public SourceList As New List(Of MyValueExpression)

        Public Sub New(ByVal exp1 As MyDataExpressionBase, ByVal sourceList As List(Of MyValueExpression))
            Me.New(exp1, MyContainsOperator.Contains, sourceList)
        End Sub

        Public Sub New(ByVal exp1 As MyDataExpressionBase, ByVal op As MyContainsOperator, ByVal sourceList As List(Of MyValueExpression))
            Me.Expression1 = exp1
            Me.op = op
            Me.SourceList = sourceList
        End Sub

        Public Overrides Function ToString() As String
            Dim sql As New MyStringBuilder

            sql.AppendFormat("{0} {1} (", Me.Expression1, Me.op)

            Dim expressions As New List(Of String)

            expressions.Clear()

            For Each exp As MyValueExpression In Me.SourceList
                expressions.Add(exp.ToString())
            Next

            sql.AppendFormat(String.Join(",", expressions.ToArray()))

            sql.AppendFormat(")")

            Return sql.ToString()
        End Function

    End Class
End Namespace

